<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div class="app">
        <p>cont的值是{{cont}}</p>
        <button v-on:click="addCont(1)">+1</button>
        <button v-on:click="subCont(1)">-1</button>
    </div>
    <script>
        const vm = new Vue({
            el: ".app",
            data:{
                cont: 4,
            },
            // methods 就是定义事件的处理函数
            methods: {
                addCont(n){
                    console.log(this)
                    this.cont += n
                },
                subCont(n){
                    this.cont -= n
                }
            }
        })
    </script>
</body>
</html>